home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 41
/
Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso
/
-seriously_amiga-
/
misc
/
nilnull
/
null
/
null.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-04-19
|
3KB
|
144 lines
/*
** $VER: misc.c 1.0 (4.4.99)
**
** main handler routine
**
** modified 1999 by Andreas R. Kleinert
** Original Copyright below.
*/
/****************************************************************************
*
* null driver V0.0 (c)CopyRight 1988, Gunnar Nordmark. All Rights Reserved.
*
* null-handler Ver. 0.0 20-Jul-1988
*
* Gunnar Nordmark
* Nora strand 5
* 182 34 DANDERYD
* SWEDEN
*
* |You may freely distribute this source as long as |
* |the Copyright notice is left intact. |
***************************************************************************/
#define __USE_SYSBASE
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/ports.h>
#include <exec/libraries.h>
#include <exec/devices.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <dos/filehandler.h>
#include <devices/console.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "misc.h"
UBYTE __aligned version[] = "\0$VER: null 1.0 (4.4.99)";
/* My Globals */
struct ExecBase *SysBase = NULL;
struct Process *myproc = NULL;
void __saveds start(void)
{
struct DosPacket *mypkt; /* a pointer to the dos packet */
struct DeviceNode *mynode; /* our device node (parmpkt Arg3) */
struct FileHandle *fh; /* a pointer to our file handle */
long run = TRUE; /* handler main loop flag */
int null_open = 0; /* null open count */
/* Initializing the handler */
SysBase = (*((struct ExecBase **) 4));
myproc = (struct Process *)FindTask(NULL);
mypkt = taskwait(myproc); /* Wait for my startup message */
/* I don't need the name or extra info passed in Arg1/2 */
mynode = (struct DeviceNode *)BADDR(mypkt->dp_Arg3);
mynode->dn_Task = &myproc->pr_MsgPort;
returnpkt(mypkt, myproc, DOSTRUE, mypkt->dp_Res2);
/* done initial stuff, now for some work */
while(run)
{
mypkt = taskwait(myproc);
switch(mypkt->dp_Type) /* find what action to perform */
{
case ACTION_FINDINPUT:
case ACTION_FINDOUTPUT:
{
null_open++;
fh = (struct FileHandle *) BADDR(mypkt->dp_Arg1);
fh->fh_Arg1 = mypkt->dp_Type;
fh->fh_Port = (struct MsgPort *) NULL; /* not interactive */
returnpkt(mypkt, myproc, DOSTRUE, mypkt->dp_Res2);
break;
}
case ACTION_READ:
{
returnpkt(mypkt, myproc, 0, mypkt->dp_Res2); /* zero-length=EOF */
break;
}
case ACTION_WRITE:
{
mypkt->dp_Res1 = mypkt->dp_Arg3; /* tell em we wrote them all */
returnpktplain(mypkt, myproc);
break;
}
case ACTION_END:
{
null_open--;
if(!null_open) run = FALSE;
returnpkt(mypkt, myproc, DOSTRUE, mypkt->dp_Res2);
break;
}
default:
{
returnpkt(mypkt, myproc, DOSFALSE, ERROR_ACTION_NOT_KNOWN);
break;
}
}
}
mynode->dn_Task = NULL;
}